<?php
class Product extends CI_Controller
{
	public function __construct()
	{
		parent::__construct();

		// load helper
		$this->load->helper('url');
		// $this->load->library('session');

		$this->load->model("Product_model", '', TRUE);
		$this->load->model("Unit_model", '', TRUE);
		$this->load->model("Provider_model", '', TRUE);
	}

	public function index($warehouseId)
	{		
		$data['lstProduct'] = $this->Product_model->All($warehouseId);

		$data['mainView'] = 'product/index';
		$data['warehouseId'] = $warehouseId;
		$this->load->view('shared/layout', $data);
	}

	public function create($warehouseId)
	{
		$data['mainView'] = 'product/create';

		$data['lstUnit'] = $this->Unit_model->All();
		$data['lstProvider'] = $this->Provider_model->All($warehouseId);

		$data['warehouseId'] = $warehouseId;
		$this->load->view('shared/layout', $data);
	}	

	public function create_post($warehouseId)
	{
		$this->Product_model->Add($warehouseId);

		redirect("/product/index/$warehouseId");
	}	
}
?>